package com.css.fxfzxczh.modules.samplingPointDataCensus.classifiedStatistics.controller;

import com.css.fxfzxczh.base.response.RestResponse;
import com.css.fxfzxczh.modules.samplingPointDataCensus.classifiedStatistics.service.ClassifiedStatisticsService;
import com.css.fxfzxczh.modules.samplingPointDataCensus.classifiedStatistics.service.impl.ClassifiedStatisticsServiceImpl;
import com.css.fxfzxczh.modules.samplingPointDataCensus.param.QueryParam;
import com.css.fxfzxczh.util.PlatformPageUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Author: zhangSongRui
 * @CreateTime: 2023/02/22
 * @Description: 评估区分类统计
 */
@RestController
@RequestMapping("/classifiedStatistics")
@Slf4j
@Api(tags = "评估区分类统计")
public class ClassifiedStatisticsController {

    @Autowired
    ClassifiedStatisticsService classifiedStatisticsService;

    /**
     * 获取结构类型面积占比
     * @param queryParam
     * @return
     */
    @GetMapping("/getStructureAreaProportion")
    public RestResponse getStructureAreaProportion(QueryParam queryParam){
        RestResponse response = null;
        try{

            List<Map<String,Object>> list=classifiedStatisticsService.getStructureAreaProportion(queryParam);
            response = RestResponse.succeed(list);
        }catch (Exception e){
            String errorMessage = "获取失败!";
            log.error(errorMessage,e);
            response = RestResponse.fail(errorMessage);
        }
        return response;
    }

    /**
     * 获取不同破坏程度面积占比
     * @param queryParam
     * @return
     */
    @GetMapping("/getDamageAreaProportion")
    public RestResponse getDamageAreaProportion(QueryParam queryParam){
        RestResponse response = null;
        try{

            List<Map<String,Object>> map=classifiedStatisticsService.getDamageAreaProportion(queryParam);
            response = RestResponse.succeed(map);
        }catch (Exception e){
            String errorMessage = "获取失败!";
            log.error(errorMessage,e);
            response = RestResponse.fail(errorMessage);
        }
        return response;
    }
}
